<template>
 
    <div class="body" style="height:100vh" v-loading.body="listLoading">
    <div>
      <NavBar
  title="2019部门绩效排名"
/>
    </div>
    
    <el-table style="width:100%;" :data="list"  element-loading-text="Loading" border fit highlight-current-row>
         <el-table-column label="排名"   align="center">
        <template slot-scope="scope">
          {{scope.$index+1}}
        </template>
      </el-table-column>
      <el-table-column  label="部门" align="center">
        <template slot-scope="scope">
          {{scope.row['部门']}}
        </template>
      </el-table-column>
      <el-table-column  label="总分" prop='总分' align="center">
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import linq from "linq"
  import {loadDep} from '@/api/department_score'
  import NavBar from "../../components/NavBar/navBar";

  export default {
    components: {
    NavBar
   },
    data() {
      
      return {
        list: [],
        items: [],
        detailModel: null,
        showEdit: false,
        scoreList: [],
        dlgVisible: false,
        selectDep: null,
        年份: '2019',
        listLoading: false,
        deps: [ 
            "创新强校办公室", 
        "人事处", 
        "党政办公室", 
        "后勤管理处", 
        "党委学生工作部", 
        "创新创业学院", 
        "教务处", 
        "图书馆", 
        "资产管理处", 
        "保卫处", 
        "心理中心", 
        "基建工程管理中心",
"外事办", 
        "科技与校企合作处", 
        "实训中心", 
        "党委组织部", 
        "工会", 
        "财务处", 
        "信息中心", 
        "审计处"
          ],
      }
    },
    async created(){
        await this.fetchData();
    },
    methods: {
     
      async fetchData() {
        //
        //let teacher = getUser();
        this.listLoading = true;
        var datas = [];
       
      
         if( this.$root.user.role.indexOf("校领导") !== -1 ||
             this.$root.user.role.indexOf("人事处") !== -1
        ){
             datas = await  Promise.all(this.deps.map(async (item)=>{
           let data = await loadDep(item,this.年份);
           return data;
        }))
        }else if(this.deps.indexOf(this.$root.user.教师所属系部) !==-1)
        {
             let res =   await loadDep(this.$root.user.教师所属系部,this.年份);
             datas.push(res);
        }
        this.list = linq.from(datas).orderByDescending("$.总分").toArray();

        this.listLoading = false;
        //
        //
      }
    }
  }
</script>
